﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace yichu_front
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //if (DateTime.Today > DateTime.Parse("2024-10-30"))
            //{
            //    return;
            //}
            if (System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1)
            {

            }
            else
            {
                //查询看有没有本机的mac
                //读取MAC地址
                string mac = Pub.GetMacAddressByNetworkInformation();
                string macGTP = Pub.GetMacAddressGPT();
                string macconfig = ConfigurationManager.AppSettings["mac"];
                //MD5 MAC地址
                string MD5MAC = Util.MySecurity.GetMD5(mac + "!#%&1357QETU");
                string MD5MACGTP = Util.MySecurity.GetMD5(macGTP + "!#%&1357QETU");
                string MD5MACconfig = Util.MySecurity.GetMD5(macconfig + "!#%&1357QETU");

                if (SqlSugarHelp.scope.Queryable<Author>().Where(it => it.MAC == mac && it.MD5MAC == MD5MAC).Any())
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form_Login());
                    //Application.Run(new Form_Register());


                }
                else if (SqlSugarHelp.scope.Queryable<Author>().Where(it => it.MAC == macGTP && it.MD5MAC == MD5MACGTP).Any())
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form_Login());
                    //Application.Run(new Form_Register());


                }
                if (SqlSugarHelp.scope.Queryable<Author>().Where(it => it.MAC == macconfig && it.MD5MAC == MD5MACconfig).Any())
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form_Login());
                }
                else
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form_Register());
                }

            }
        }

        
    }
}
